<link href="/statics/plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="/statics/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<script type="text/javascript" src="/statics/plugins/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<div class="box box-solid">
    <?php $this->widget('UserNavWidget');?>
    <div class="box-body table-responsive ">
    <div class="box-header">
    <div >
        <form role="form" action="/admin/user/list" method="get">
            <div class="input-group">

                          <label class="pull_left">
                              <label>起始时间</label>
                              <input type="input" name="min_time" class="form-control" readonly="readonly" value="<?php if(!empty($filters['min_time']) && is_numeric($filters['min_time'])){echo date('Y-m-d H:i',$filters['min_time']);} ?><?php if (!empty($filters['min_time']) && !is_numeric($filters['min_time']) ) { echo $filters['min_time'];
                              } ?>" id="duration_begin" style="width:150px;margin:5px;"/>
                              <label>截止时间</label>
                              <input type="input" name="max_time" class="form-control" readonly="readonly" value="<?php if(!empty($filters['max_time']) && is_numeric($filters['max_time'])){echo date('Y-m-d H:i',$filters['max_time']);} ?><?php if (!empty($filters['max_time']) && !is_numeric($filters['max_time']) ) { echo $filters['max_time'];
                              } ?>" id="duration_end" style="width:150px;margin:5px;"/>
                          </label>


                    <label class="pull-right">
                        <input type="text" name="name" class="form-control input-sm " style="width: 150px;" placeholder="姓名" value=<?php echo $filters['name'];?> >
                    </label>
                    <label class="pull-right">
                        <input type="text" name="mobile" class="form-control input-sm " style="width: 150px;" placeholder="账号" value=<?php echo $filters['mobile'];?> >
                    </label>

                    <input type="hidden" name="page" value="1"/>
                    <div class="input-group-btn">
                        <button class="btn btn-sm btn-primary"  >搜索<i class="fa fa-search"></i></button>
                        <a href="/admin/user/list" class="btn btn-sm btn-default">清空条件</a>
                    </div>

            </div>
        </form>
    </div>
</div>
   <?php if(!empty($user['data'])){ ?>
        <table class="table table-hover table-bordered">

                <tr>
                <th>账号</th>
                <th>状态</th>
                <th>姓名</th>
                <th>昵称</th>
                <th>货主</th>
                <th>承运人</th>
                <th>注册时间</th>
                <th>收发货地址</th>
                <th class="align-center">操作</th>

            </tr>

      <?php foreach ($user['data'] as $key => $value) { ?>
        <tr>
            <td><?php echo $value['mobile']; ?></td>
            <td>
                <?php if($value['status'] == 1) : ?>
                    <span><b style="color:green">正常</b></span>
                <?php  else : ?>
                    <span class="f_red"><b style="color:red">已禁用</b></span>
                <?php endif; ?>
            </td>


            <td><?php if(!empty($value['name'])) echo $value['name'];else echo '';?>
            </td>
            <td><?php if(!empty($value['nickname'])) echo $value['nickname'];else echo '';?>
            </td>

            <td>
            <?php if($value['authentication']==0):?>

                <?php if($value['apply_status']['personshipper']==1):?>

                    <a  target="_blank" href="<?php echo $this->createUrl('user/applylist/role_type/1/sid/'.$value['sid']); ?>">申请认证个人</a>
                <?php elseif($value['apply_status']['enterpriseshipper']==1):?>
                    <a  target="_blank" href="<?php echo $this->createUrl('user/applylist/role_type/1/sid/'.$value['sid']); ?>">申请认证企业</a>
                <?php else:?>
                    未认证
               <?php endif;?>

            <?php elseif($value['authentication']==1):?>

                <?php if($value['apply_status']['enterpriseshipper']==1):?>
                    <a  target="_blank" href="<?php echo $this->createUrl('user/applylist/role_type/1/sid/'.$value['sid']); ?>">申请认证企业</a>
                <?php else:?>
                    个人货主
                <?php endif;?>
            <?php else:?>
                企业货主
            <?php endif;?>
             </td>

           <td>

            <?php if($value['apply']==0):?>

                <?php if($value['apply_status']['personcarry']==1):?>

                    <a target="_blank" href="<?php echo $this->createUrl('user/applylist/role_type/2/sid/'.$value['sid']); ?>">申请认证个人</a>
                <?php elseif($value['apply_status']['enterprisecarry']==1):?>
                    <a  target="_blank" href="<?php echo $this->createUrl('user/applylist/role_type/2/sid/'.$value['sid']); ?>">申请认证企业</a>
                <?php else:?>
                    未认证
               <?php endif;?>

            <?php elseif($value['apply']==3):?>

                <?php if($value['apply_status']['enterprisecarry']==1):?>
                    <a  target="_blank" href="<?php echo $this->createUrl('user/applylist/role_type/2/sid/'.$value['sid']); ?>">申请认证企业</a>
                <?php else:?>
                    个人承运人
                <?php endif;?>
            <?php else:?>
                企业承运人
            <?php endif;?>


           </td>

            <td>
                <?php echo date('Y-m-d H:i',$value['ctime']); ?>
            </td>
            <td>
                <?php echo  $value['address_num']; ?>
                <a  href="<?php echo $this->createUrl('address/list/sid/'.$value['sid']); ?>">查看</a>
            </td>
            <td class="align-center tool-bar">
                <?php if (1 == 1) : ?>
                    <a  href="<?php echo $this->createUrl('user/resetpwd/sid/'.$value['sid']); ?>">重置密码</a>
                            <!-- 判断用户权限 -->
                    <?php if($this->admin_name == 'admin' || !array_key_exists('user/detail',$this->sp['用户']) || (array_key_exists('user/detail',$this->sp['用户']) && in_array('user/detail',$this->user_sp))): ?>
                    <a  href="<?php echo $this->createUrl('user/info/sid/'.$value['sid']); ?>">详情</a>
                     <?php endif; ?>


                <?php if($this->admin_name == 'admin' || !array_key_exists('user/status',$this->sp['用户']) || (array_key_exists('user/status',$this->sp['用户']) && in_array('user/status',$this->user_sp))): ?>

                    <?php if($value['status'] == User::STATUS_NORMAL) : ?>
                        <a onclick="return confirm('确定要禁用吗？');" href="<?php echo $this->createUrl('user/status/sid/'.$value['sid']); ?>">禁用</a>
                    <?php  else : ?>
                        <a onclick="return confirm('确定要解禁吗？');" href="<?php echo $this->createUrl('user/status/sid/'.$value['sid']); ?>">启用</a>
                    <?php endif; ?>

                <?php endif; ?>

              <?php endif; ?>
            </td>
        </tr>
            <?php }?>
        <?php }else{
            echo '没有子用户';
            }?>
        <a href="<?php echo $this->createUrl('/admin/user/info',array('sid'=>Yii::app()->request->getQuery('sid'))); ?>">返回用户详情</a>
        </table>
        
    </div>
    <div class="box-footer clearfix">

    <?php if(!empty($user['data'])): ?>

        <?php $this->widget('BLinkPager', array('pages'=>$user['pager'])); ?>
    <?php endif; ?>
    </div>

</div>
    <script>
        $(function(){
            $("#duration_begin").datetimepicker({
                language:'zh-CN',
                autoclose:1,
                maxView:3
            });
            $("#duration_end").datetimepicker({
                language:'zh-CN',
                autoclose:1,
                maxView:3
            });
        });
    </script>
